package com.wenli.lt.Aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

@Aspect
@Component
public class Point {
    @Before("execution(* com.wenli.lt.Aspect.Buy.Play(..))")
    public void Before(ProceedingJoinPoint point) {
        System.out.println("男孩女都有自己喜欢的事情");
    }

    @Around("execution(* com.wenli.lt.Aspect.Buy.Play(..))")
    public void Around(ProceedingJoinPoint point) throws Throwable {
        System.out.println("环绕前.....");
        System.out.println(point);
        /**
         * 得到参数
         */
        Object[] args = point.getArgs();
        System.out.println("args=> " + args.toString());
        /**
         * 得到切入点的类型
         */
        String kind = point.getKind();
        System.out.println("kind=> " + kind);
        /**
         *  切入点 得到被增强方法的方法签名
         */
        MethodSignature methodSignature = (MethodSignature) point.getSignature();

        /**
         *  方法签名 到被增强方法的方法
         */
        Method method = methodSignature.getMethod();
        System.out.println("method = > " + method);
        /**
         *  方法 名 到被增强方法的方法 上面的注解
         */

        Signature signature = point.getSignature();
        String name = signature.getName();
        Class declaringType = signature.getDeclaringType();
        int modifiers = signature.getModifiers();
        String declaringTypeName = signature.getDeclaringTypeName();
        System.out.println("name= > " + name + " declaringType => " + declaringType + " modifiers => " + modifiers + " declaringTypeName => " + modifiers);
        System.out.println("signature=> " + signature);
        /**
         *    得到目标
         */
        Object target = point.getTarget();
        System.out.println("target=> " + target);
        System.out.println("环绕后.....");
    }


}
